("Find all devices on the network:", "hp-probe -bnet", "example", False),
("Find all devices on USB that support scanning:", "hp-probe -busb -escan", "example", False),
("Find all networked devices that contain the name 'lnx' and that support photo cards or scanning:", "hp-probe -bnet -slnx -escan,pcard", "example", False),
("Find all devices that have queues installed in CUPS:", "hp-probe -bcups", "example", False),
("Find all devices on the USB bus:", "hp-probe", "example", False),
]
try:
mod = module.Module(__mod__, __title__, __version__, __doc__, USAGE,
(INTERACTIVE_MODE,))
opts, device_uri, printer_name, mode, ui_toolkit, loc = \
mod.parseStdOpts('b:t:o:e:s:m:',
['ttl=', 'filter=', 'search=', 'find=',
'method=', 'time-out=', 'timeout=', 'bus='],
handle_device_printer=False)
bus = None
timeout=10
ttl=4
filter = []
search = ''
method = 'slp'
for o, a in opts:
if o in ('-b', '--bus'):
try:
bus = [x.lower().strip() for x in a.split(',')]
except TypeError:
bus = ['usb']
if not device.validateBusList(bus):
mod.usage(error_msg=['Invalid bus name'])
elif o in ('-m', '--method'):
method = a.lower().strip()
if method not in ('slp', 'mdns', 'bonjour'):
mod.usage(error_msg=["Invalid network search protocol name. Must be 'slp' or 'mdns'."])
else:
bus = ['net']
elif o in ('-t', '--ttl'):
try:
ttl = int(a)
except ValueError:
ttl = 4
log.note("TTL value error. TTL set to default of 4 hops.")
elif o in ('-o', '--timeout', '--time-out'):
try:
timeout = int(a)
if timeout > 45:
log.note("Timeout > 45secs. Setting to 45secs.")
timeout = 45
except ValueError:
timeout = 5
log.note("Timeout value error. Timeout set to default of 5secs.")
if timeout < 0:
mod.usage(error_msg=["You must specify a positive timeout in seconds."])
elif o in ('-e', '--filter'):
filter = [x.strip().lower() for x in a.split(',')]
if not device.validateFilterList(filter):
mod.usage(error_msg=["Invalid term in filter"])
elif o in ('-s', '--search', '--find'):
search = a.lower().strip()
if bus is None:
bus = tui.connection_table()
if bus is None:
sys.exit(0)
log.info("\nUsing connection type: %s" % bus[0])
log.info("")
tui.header("DEVICE DISCOVERY")
for b in bus:
if b == 'net':
log.info(log.bold("Probing network for printers. Please wait, this will take approx. %d seconds...\n" % timeout))